/**
 * 封装请求方法
 *  url  接口请求地址
 *  data 接口请求参数（无需请求方式参数，则此项可以为空，否则必须传）
 *  para 请求方式参数（可以为空）
 *  callback 回调函数
 */
function $_request(url, data, callback, para) {
  $.ajax({
    url: APP_URL + url,
    type: para && para.type || 'POST',
    dataType: para && para.dataType || 'JSON',
    data: JSON.stringify(data),
    beforeSend: function () {

    },
    success: function (res) {
      callback(res);
    },
    error: function (res) {
      new LightTip().error(res);
    },
    headers: {
      "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content'),
    }
  });
}

function getQueryVariable(variable)
{
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if(pair[0] == variable){return pair[1];}
  }
  return(false);
}

//首页
function getHzlUserInfo(data, callback, params){ return $_request('/mobile/getHzlUserInfo', data, callback, params) }//获取汇治理用户信息
function studentLogin(data, callback, params){ return $_request('/mobile/studentLogin', data, callback, params) }//学生用户登录
function bindStudent(data, callback, params){ return $_request('/mobile/bindStudent', data, callback, params) }//初始绑定学生
function addStudent(data, callback, params){ return $_request('/mobile/addStudent', data, callback, params) }//添加学生信息
function getCarousels(data, callback, params){ return $_request('/mobile/index/getCarousels', data, callback, params) }//获取轮播图
function getActivityTypes(data, callback, params){ return $_request('/mobile/index/getActivityTypes', data, callback, params) }//获取活动类型字典
function getStages(data, callback, params){ return $_request('/mobile/index/getStages', data, callback, params) }//获取学段字典
function getActivities(data, callback, params){ return $_request('/mobile/index/getActivities', data, callback, params) }//获取活动列表
function getActivityDetail(data, callback, params){ return $_request('/mobile/index/getActivityDetail', data, callback, params) }//获取活动详情
function getActivityExtendInfo(data, callback, params){ return $_request('/mobile/index/getActivityExtendInfo', data, callback, params) }//获取活动拓展信息
function favoriteActivity(data, callback, params){ return $_request('/mobile/index/favoriteActivity', data, callback, params) }//收藏活动
function unFavoriteActivity(data, callback, params){ return $_request('/mobile/index/unFavoriteActivity', data, callback, params) }//取消收藏活动
function applyActivity(data, callback, params){ return $_request('/mobile/index/applyActivity', data, callback, params) }//报名
function getTeamParticipant(data, callback, params){ return $_request('/mobile/index/getTeamParticipant', data, callback, params) }//获取团队报名信息
function queryStudents(data, callback, params){ return $_request('/mobile/index/queryStudents', data, callback, params) }//查询学生

//我的活动
function getMyActivities(data, callback, params){ return $_request('/mobile/myactivity/getMyActivities', data, callback, params) }//查询我的活动列表
function getFlowList(data, callback, params){ return $_request('/mobile/myactivity/getFlowList', data, callback, params) }//查询活动阶段列表
function getMyActivityDetail(data, callback, params){ return $_request('/mobile/myactivity/getActivityDetail', data, callback, params) }//获取活动详情
function getMyActivityDetail2(data, callback, params){ return $_request('/mobile/myactivity/getActivityDetail2', data, callback, params) }//获取活动详情
function getActivityResult(data, callback, params){ return $_request('/mobile/myactivity/getActivityResult', data, callback, params) }//获取活动成绩
function getExcellentProducts(data, callback, params){ return $_request('/mobile/myactivity/getExcellentProducts', data, callback, params) }//获取优秀作品
function getEntryDetail(data, callback, params){ return $_request('/mobile/myactivity/getEntryDetail', data, callback, params) }//获取优秀作品详情
function submitEntry(data, callback, params){ return $_request('/mobile/myactivity/submitEntry', data, callback, params) }//提交作品
function getFlowMembers(data, callback, params){ return $_request('/mobile/myactivity/getFlowMembers', data, callback, params) }//获取活动阶段入围名单
function getFlowDetail(data, callback, params){ return $_request('/mobile/myactivity/getFlowDetail', data, callback, params) }//获取活动阶段详情

//我的信息
function getMyInfo(data, callback, params){ return $_request('/mobile/myinfo/getMyInfo', data, callback, params) }//查询我的信息
function qryStudent(data, callback, params){ return $_request('/mobile/qryStudent', data, callback, params) }//查询学生
function qrySchools(data, callback, params){ return $_request('/mobile/qrySchools', data, callback, params) }//查询学校
function reBindStudent(data, callback, params){ return $_request('/mobile/myinfo/reBindStudent', data, callback, params) }//更改绑定
function unBindStudent(data, callback, params){ return $_request('/mobile/myinfo/unBindStudent', data, callback, params) }//解除绑定
function getMsgList(data, callback, params){ return $_request('/mobile/myinfo/getMsgList', data, callback, params) }//消息列表
function getMyFavorites(data, callback, params){ return $_request('/mobile/myinfo/getMyFavorites', data, callback, params) }//我的收藏列表
function getFavoriteDetail(data, callback, params){ return $_request('/mobile/myinfo/getFavoriteDetail', data, callback, params) }//我的收藏详情
function getReportDetail(data, callback, params){ return $_request('/mobile/myinfo/getReportDetail', data, callback, params) }//我的活动报告详情
